<?php

namespace App\Http\Controllers;

class BaseController extends Controller
{
    public function success($data = [],$msg ='请求成功')
    {
        if (is_string($data)){
            return response()->json(['code' => 200,'msg' => $data]);
        }


        return response()->json(['code' => 200,'data' => $data, 'msg' => $msg]);
    }


    public function error($msg = '请求失败')
    {
        return response()->json(['code' => 500,'msg' => $msg]);
    }
}
